//
//  CityPlayerViewController.m
//  LanQiuQuan
//
//  Created by TonyGenius on 16/4/28.
//  Copyright © 2016年 Rip. All rights reserved.
//

#import "CityPlayerViewController.h"
#import "PlayerTableViewCell.h"
#import "SHSearchView.h"

@interface CityPlayerViewController ()<UITableViewDataSource, UITableViewDelegate, UIScrollViewDelegate>
{
    XMTabBarController *_tab;
}
@property (weak, nonatomic) IBOutlet UITableView *tableView;

@property (nonatomic, strong) NSMutableArray *playerlist;
@end

@implementation CityPlayerViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self initTableView];
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"] style:UIBarButtonItemStyleDone target:self action:@selector(back)];
    
    backItem.tintColor = [UIColor whiteColor];
    self.navigationItem.leftBarButtonItem = backItem;
    self.navigationItem.title = @"同城球员";
}

- (void)viewWillAppear:(BOOL)animated
{
    _tab = (XMTabBarController *)self.tabBarController;
    [_tab xmTabBarHidden:YES animated:YES];
}

- (void)initTableView
{
    [_tableView registerNib:[UINib nibWithNibName:@"PlayerTableViewCell" bundle:nil] forCellReuseIdentifier:@"playerCell"];
    UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tableViewBG"]];
    [_tableView setBackgroundView:image];
}

- (void)back
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    PlayerTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"playerCell" forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = [UIColor clearColor];
    SHSearchView *search = [[NSBundle mainBundle] loadNibNamed:@"SHSearchView" owner:self options:nil][0];
    
    search.frame = CGRectMake(0, 0, view.bounds.size.width, view.bounds.size.height);
    search.backgroundColor = [UIColor clearColor];
    [view addSubview:search];
    
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 44;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 93;
}

- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
{
    [self.view endEditing:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        self.hidesBottomBarWhenPushed = YES;
    }
    return self;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
